package collection;

import sun.security.provider.ConfigFile;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

public class CollectionDemo {
    public static void main(String[] args) {
        Collection c = new ArrayList();
        c.add(new Point(1, 2));
        c.add(new Point(3, 4));
        c.add(new Point(4, 5));
        c.add(new Point(6, 7));
        c.add(new Point(8, 9));
        System.out.println(c);
        Point p = new Point(1, 2);
        //contains判断当前集合是否包含给定元素
        boolean a = c.contains(p);
        System.out.println(a);
        /*boolean remove
        从当前集合移除给定元素o，equals（）比较为true的元素
         */
        c.remove(p);
        System.out.println(c);
        //集合装的是元素的地址
        Collection cc = new ArrayList();
        Point pp = new Point(1, 2);
        cc.add(pp);
        System.out.println(pp);
        System.out.println(cc);
        pp.setX(1000);
        System.out.println(pp);
        System.out.println(cc);


















        Collection c1=new ArrayList();
        c1.add("123");
        c1.add("456");
        c1.add("789");
        c1.add(535);
        c1.add(54);
        //size 元素个数
        System.out.println(c+"元素个数："+c.size());
        //isEmpty()判断集合是否为空集
        System.out.println("是否为空集："+c.isEmpty());
        //clear清空集合
        c1.clear();
        System.out.println("集合清空");
        System.out.println(c1);
        System.out.println("size:"+c.size());
        System.out.println(c.isEmpty());


    }
}
